package com.effective.java.chapter02;

import java.util.regex.Pattern;

public class NotCreateObj06 {
    private static final Pattern pattern = Pattern.compile("^(?=.)M*$");

    public static boolean check(String s) {
        return pattern.matcher(s).matches();
    }

    public static long sum() {
//        Long sum = 0L;  // 16576ms
        long sum = 0L;  // 2070ms
        for (long i = 0; i < Integer.MAX_VALUE; ++i) {
            sum += i;
        }
        return sum;
    }

    public static void main(String[] args) {
        long start = System.currentTimeMillis();
        System.out.println(sum());
        System.out.println(System.currentTimeMillis() - start);
    }
}
